package com.test.controller;

import com.test.entity.GoodsParam;
import com.test.entity.Student;
import com.test.service.StudentService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller

public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("list")
    public String list(Model model, GoodsParam p){
        int count = studentService.getCount(p);
        p.setPageSize(3);
        p.setTotal(count);
        List<Student> sList = studentService.getStuList(p);
        model.addAttribute("slist",sList);
        model.addAttribute("p",p);
        System.out.println();
        return "list";
    }

    @RequestMapping("delAll")
    public String delAll(@Param("ids") String ids){
        System.out.println(ids);
        studentService.delAll(ids);
        return "redirect:/list";

    }
}
